package com.example.mybatisplusdemo.mapper;

import com.baomidou.mybatisplus.annotations.SqlParser;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.example.mybatisplusdemo.entity.User;
import com.example.mybatisplusdemo.model.vo.UserVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * User 表数据库控制层接口
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 注解SQL方式查询
     * 注解 @SqlParser(filter = true) 过滤多租户解析
     */
    @SqlParser(filter = true)
    @Select("select t1.test_id as id, t1.name, t1.age, t1.test_type,t1.test_date, t2.name as role_name from user t1 left join role t2 on t1.role = t2.id")
    List<UserVO> listWithRole();

    /**
     * 传统方式查询
     * @return
     */
    List<User> listAll();

}